package pe.edu.ups.studio.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pe.edu.upc.studio.excepcion.DAOExcepcion;

import pe.edu.upc.studio.negocio.ReservaSalaNegocio;

/**
 * Servlet implementation class CancelarReserva
 */
@WebServlet("/CancelarReserva")
public class CancelarReserva extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public CancelarReserva() {
		super();

	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		int id = Integer.parseInt(request.getParameter("id"));
		ReservaSalaNegocio dao = new ReservaSalaNegocio();
		try {
			dao.CancelarReserva(id);
			response.sendRedirect("consultareservas.jsp");
		} catch (DAOExcepcion e) {
			String msj = e.getMessage();
			RequestDispatcher rd = request
					.getRequestDispatcher("/error.jsp?error=" + msj);
			rd.forward(request, response);
		}
		
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
	}

}
